home *** CD-ROM | disk | FTP | other *** search
- /*
- * 10bit固定小数演算 v. 1.0
- * math.h を仮定する。
- */
-
- /*
- * x, y は固定少数に限定するよう, 注意して使う。
- * 足し算, 引き算はそのまま。 dummy で作ってもいいかもしれない。
- */
- #define multi( x, y ) ( (x) * (y) >> DECIMAL )
- #define div( x, y ) ( (x) / (y) << DECIMAL )
-
- /*
- * int multi( int x, int y ) { return x*y >> DECIMAL ;}
- * int div (int x,int y) { return x/y << DECIMAL ;}
- */
-
- extern int powd( int, int ) ;
-
- /*
- * 小さい変数のための三角関数( 小さくマクローリン展開しただけ。 べきの展開の大きさは個別に tune せよ。)
- * 返り値も固定少数表現の整数である。 (COS for Small Decimal)
- */
- #define cossd( x ) ( DUNIT - powd( (x), 2 )/2 + powd( (x), 4 )/24 - powd( (x), 6 )/720 )
- #define sinsd( x ) ( (x) - powd( (x), 3 )/6 + powd( (x), 5 )/120 - powd( (x), 7)/5040 )
-
- /*
- * 三角数列。 そのまま cos, sin の関数とみなす。
- */
- extern int cos512[1024];
- extern int sin512[1024];
- extern int acos512[2048+1];
- extern int asin512[2048+1];
- #define cos512( x ) (cos512[x])
- #define sin512( x ) (sin512[x])
- #define acos512( x ) (acos512[(x)+DUNIT])
- #define asin512( x ) (asin512[(x)+DUNIT])
- /* -DUNIT は負に対応するため, 数列は原点をずらして持っている。 */
-